<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="generator" content="rustdoc">
    <title>Native Windows GUI guide - Helpers</title>

    <link rel="stylesheet" type="text/css" href="style/rustbook.css">
    <link rel="stylesheet" type="text/css" href="style/pygments.css">
    <link rel="stylesheet" type="text/css" href="style/nwg.css">


</head>
<body class="rustdoc">
<!--[if lte IE 8]>
<div class="warning">
    This old browser is unsupported and will most likely display funky
    things.
</div>
<![endif]-->

<!-- NAV BEGIN -->
<div id="nav">
    <button id="toggle-nav">
        <span class="sr-only">Toggle navigation</span>
        <span class="bar"></span>
        <span class="bar"></span>
        <span class="bar"></span>
    </button>
</div>

    
<div id='toc' class='mobile-hidden'>
<ul class='chapter'>
<li><a href='index.html'><b>1.</b> Introduction</a>
</li>
<li><a href='getting_started.html'><b>2.</b> Getting Started</a>
</li>

<li><a href="basics.html"><b>3.</b> Basics </a>
<ul class="section">
    <li><a href="controls.html"><b>3.1.</b> Controls </a></li>
    <li><a href="events.html"><b>3.2.</b> Events </a></li>
    <li><a href="helper.html"><b>3.3.</b> Helpers </a></li>
    <li><a href="small.html"><b>3.4.</b> Small application layout </a></li>
    <li><a href="limitations.html"><b>3.5.</b> Limitations </a></li>
    <li><a href="distribute.html"><b>3.6.</b> Distributing </a></li>
    <li><a href="features.html"><b>3.7.</b> Features </a></li>
</ul>
</li>

<li><a href="intermediate.html"><b>4.</b> Intermediate </a>
<ul class="section">
    <li><a href="layouts.html"><b>4.1.</b> Layouts </a></li>
    <li><a href="resources.html"><b>4.2.</b> Resources </a></li>
    <li><a href="dialogs.html"><b>4.3.</b> Dialogs </a></li>
    <li><a href="localization.html"><b>4.4.</b> Internationalization </a></li>
</ul>
</li>

<li><a href="advanced.html"><b>5.</b> Advanced </a>
<ul class="section">
    <li><a href="partial.html"><b>5.1.</b> Partials ui </a></li>
    <li><a href="dynamic_control.html"><b>5.2.</b> Dynamic control </a></li>
    <li><a href="dynamic_event.html"><b>5.3.</b> Dynamic events </a></li>
    <li><a href="multithreading.html"><b>5.4.</b> Multithreading </a></li>
</ul>
</li>

<li><a href="derive.html"><b>6.</b> Native-windows-derive </a>
<ul class="section">
    <li><a href="nwd_basics.html"><b>6.1.</b> Basics </a></li>
    <li><a href="nwd_controls.html"><b>6.1.</b> Controls </a></li>
    <li><a href="nwd_resources.html"><b>6.2.</b> Resources </a></li>
    <li><a href="nwd_events.html"><b>6.3.</b> Events </a></li>
    <li><a href="nwd_layouts.html"><b>6.4.</b> Layouts </a></li>
    <li><a href="nwd_partial.html"><b>6.5.</b> Partials </a></li>
</ul>
</li>

<li><a href="low.html"><b>7.</b> Low level stuff </a>
    <ul class="section">
        <li><a href="low_events.html"><b>7.1.</b> Raw event handling </a></li>
        <li><a href="extern_wrapping.html"><b>7.2.</b> Raw control handle </a></li>
    </ul>
</li>

</ul>
</div>
<!-- NAV END -->

<div id='page-wrapper'>
    <div id='page'>

        <h1 class="title">Native Windows GUI: Helpers</h1>

        Outside of the controls, the resources, and the layouts NWG also has some utility functions. This section will go over them.
        <br/><br/>

        <h3>Automatic styling</h3>

        NWG use a hack to implement visual style in applications without having to use a manifest file (<a href="https://docs.microsoft.com/en-us/windows/win32/controls/cookbook-overview">see this</a>)
        This is a good thing because linking a manifest requires a third party library (such as <a href="https://github.com/nabijaczleweli/rust-embed-resource">rust-embed-resource</a>)
        <br><br>

        If automatic styling is not needed, enable the feature <code>no-styling</code><br><br>

        <h3>Message box</h3>

        In a GUI application, there's no console to display error messages to the end user. In cases like this, a message box is used.<br>
        NWG wraps the winapi message box function with the <code>message</code> or the <code>modal_message</code> function.
        <br>

        The modal variant takes a parent window parameter. The parent window is disabled during the message box duration.


<div class="highlight"><pre style="width:auto;"><span></span><span class="k">use</span><span class="w"> </span><span class="n">native_windows_gui</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="n">nwg</span><span class="p">;</span><span class="w"></span>

<span class="kd">let</span><span class="w"> </span><span class="n">p</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">nwg</span>::<span class="n">MessageParams</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">title</span>: <span class="s">&quot;Hey&quot;</span><span class="p">,</span><span class="w"></span>
<span class="w">    </span><span class="n">content</span>: <span class="s">&quot;Cats are cute&quot;</span><span class="p">,</span><span class="w"></span>
<span class="w">    </span><span class="n">buttons</span>: <span class="nc">nwg</span>::<span class="n">MessageButtons</span>::<span class="nb">Ok</span><span class="p">,</span><span class="w"></span>
<span class="w">    </span><span class="n">icons</span>: <span class="nc">nwg</span>::<span class="n">MessageIcons</span>::<span class="n">Warning</span><span class="w"></span>
<span class="p">};</span><span class="w"></span>

<span class="n">assert</span><span class="o">!</span><span class="p">(</span><span class="n">nwg</span>::<span class="n">message</span><span class="p">(</span><span class="o">&amp;</span><span class="n">p</span><span class="p">)</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="n">nwg</span>::<span class="n">MessageChoice</span>::<span class="nb">Ok</span><span class="p">)</span><span class="w"></span>
</pre></div>

        <br>

        This function might be a little to verbose for most use case, that's why NWG implements six simple interfaces (3 modal and 3 without):

        <ul>
            <li><code>fatal_message</code>: a message box with an error icon. This function panics</li>
            <li><code>error_message</code>: a message box with an error icon.</li>
            <li><code>simple_message</code>: a message box with an information icon.</li>

            <li><code>modal_fatal_message</code>: a message box with an error icon. This function panics</li>
            <li><code>modal_error_message</code>: a message box with an error icon.</li>
            <li><code>modal_info_message</code>: a message box with an information icon.</li>
        </ul>

<div class="highlight"><pre style="width:auto;"><span></span><span class="k">pub</span><span class="w"> </span><span class="k">fn</span> <span class="nf">fatal_message</span><span class="o">&lt;</span><span class="na">&#39;a</span><span class="o">&gt;</span><span class="p">(</span><span class="n">title</span>: <span class="kp">&amp;</span><span class="na">&#39;a</span><span class="w"> </span><span class="kt">str</span><span class="p">,</span><span class="w"> </span><span class="n">content</span>: <span class="kp">&amp;</span><span class="na">&#39;a</span><span class="w"> </span><span class="kt">str</span><span class="p">)</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>
<span class="k">pub</span><span class="w"> </span><span class="k">fn</span> <span class="nf">error_message</span><span class="o">&lt;</span><span class="na">&#39;a</span><span class="o">&gt;</span><span class="p">(</span><span class="n">title</span>: <span class="kp">&amp;</span><span class="na">&#39;a</span><span class="w"> </span><span class="kt">str</span><span class="p">,</span><span class="w"> </span><span class="n">content</span>: <span class="kp">&amp;</span><span class="na">&#39;a</span><span class="w"> </span><span class="kt">str</span><span class="p">)</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>
<span class="k">pub</span><span class="w"> </span><span class="k">fn</span> <span class="nf">simple_message</span><span class="o">&lt;</span><span class="na">&#39;a</span><span class="o">&gt;</span><span class="p">(</span><span class="n">title</span>: <span class="kp">&amp;</span><span class="na">&#39;a</span><span class="w"> </span><span class="kt">str</span><span class="p">,</span><span class="w"> </span><span class="n">content</span>: <span class="kp">&amp;</span><span class="na">&#39;a</span><span class="w"> </span><span class="kt">str</span><span class="p">)</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>
</pre></div><br>    

        <h3>Global Cursor</h3>
        NWG wraps the system cursor with the <code>GlobalCursor</code> object. Not to be confused with a <code>Cursor</code> object, a cursor resource file (*.cur).
        <br/><br/>

        GlobalCursor is hidden behind the <code>cursor</code> feature. Once enabled, it can be used to get/set the mouse position on screen, capture the cursor
        outside of the application, detect a dragging gesture, and set the image of the cursor globally.<br><br>

        See <a href="https://docs.rs/native-windows-gui/1.0.12/native_windows_gui/struct.GlobalCursor.html">https://docs.rs/native-windows-gui/1.0.12/native_windows_gui/struct.GlobalCursor.html</a><br><br>

        The GlobalCursor object cannot be instanced. It must be used as it is:

<div class="highlight"><pre style="width: auto;"><span></span><span class="k">use</span><span class="w"> </span><span class="n">native_windows_gui</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="n">nwg</span><span class="p">;</span><span class="w"></span>
<span class="kd">let</span><span class="w"> </span><span class="p">(</span><span class="n">x</span><span class="p">,</span><span class="n">y</span><span class="p">)</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">nwg</span>::<span class="n">GlobalCursor</span>::<span class="n">position</span><span class="p">();</span><span class="w"></span>
</pre></div><br>

        <h3>Monitor</h3>

        Sometimes you need to know the dimensions of the desktop to position Windows control. The <code>Monitor</code> object handles this. With Monitor,
        it is possible to query the main screen dimensions, the virtual screen dimensions, and the monitor screen that a top level window is currently in<br><br>

        See <a href="https://docs.rs/native-windows-gui/1.0.12/native_windows_gui/struct.Monitor.html">https://docs.rs/native-windows-gui/1.0.12/native_windows_gui/struct.Monitor.html</a><br><br>

        The Monitor object cannot be instanced. It must be used as it is:

<div class="highlight"><pre style="width:auto;"><span></span><span class="c1">// Creating and centering a window in the main monitor</span>

<span class="k">use</span><span class="w"> </span><span class="n">native_windows_gui</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="n">nwg</span><span class="p">;</span><span class="w"></span>

<span class="k">fn</span> <span class="nf">create_window</span><span class="p">(</span><span class="n">width</span>: <span class="kt">i32</span><span class="p">,</span><span class="w"> </span><span class="n">height</span>: <span class="kt">i32</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="nc">nwg</span>::<span class="n">Window</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="p">[</span><span class="n">total_width</span><span class="p">,</span><span class="w"> </span><span class="n">total_height</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="n">nwg</span>::<span class="n">Monitor</span>::<span class="n">width</span><span class="p">(),</span><span class="w"> </span><span class="n">nwg</span>::<span class="n">Monitor</span>::<span class="n">height</span><span class="p">()];</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="k">mut</span><span class="w"> </span><span class="n">window</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">nwg</span>::<span class="n">Window</span>::<span class="n">default</span><span class="p">();</span><span class="w"></span>

<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">x</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">(</span><span class="n">total_width</span><span class="o">-</span><span class="n">width</span><span class="p">)</span><span class="o">/</span><span class="mi">2</span><span class="p">;</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">y</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">(</span><span class="n">total_height</span><span class="o">-</span><span class="n">height</span><span class="p">)</span><span class="o">/</span><span class="mi">2</span><span class="p">;</span><span class="w"></span>

<span class="w">    </span><span class="n">nwg</span>::<span class="n">Window</span>::<span class="n">builder</span><span class="p">()</span><span class="w"></span>
<span class="w">        </span><span class="p">.</span><span class="n">size</span><span class="p">((</span><span class="n">width</span><span class="p">,</span><span class="w"> </span><span class="n">height</span><span class="p">))</span><span class="w"></span>
<span class="w">        </span><span class="p">.</span><span class="n">position</span><span class="p">((</span><span class="n">x</span><span class="p">,</span><span class="w"> </span><span class="n">y</span><span class="p">))</span><span class="w"></span>
<span class="w">        </span><span class="p">.</span><span class="n">build</span><span class="p">(</span><span class="o">&amp;</span><span class="k">mut</span><span class="w"> </span><span class="n">window</span><span class="p">)</span><span class="w"></span>
<span class="w">        </span><span class="p">.</span><span class="n">unwrap</span><span class="p">();</span><span class="w"></span>

<span class="w">    </span><span class="n">window</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</pre></div>
            
        
        <h3>Clipboard</h3>

        NWG also wraps the system clipboard in order to write or read data from it. The clipboard is a way to copy arbritary data from within an application
        or even between two different applications. 
        <br/><br/>

        See <a href="https://docs.rs/native-windows-gui/1.0.12/native_windows_gui/struct.Clipboard.html">https://docs.rs/native-windows-gui/1.0.12/native_windows_gui/struct.Clipboard.html</a>
        <br/><br/>

        Note that NWG clipboard intentionally keeps things simple and close to the metal. If you want to more robust API, then I recommend you look into 
        <a href="https://github.com/DoumanAsh/clipboard-win">https://github.com/DoumanAsh/clipboard-win</a><br/><br/>


        Clipboard is hidden behind the <code>clipboard</code> feature.
        <br><br>

        <h4>Writing/Reading text</h4>

        Because reading or writing text will probably be the most used feature, NWG includes helpers functions that handles the unsafy bits.
        One thing to note is that Windows clipboard functions always take a control parameter. This can be any <code>HWND</code> based controls (ex: Window, Button, etc). 
        <br><br>

<div class="highlight"><pre style="width: auto;"><span></span><span class="k">use</span><span class="w"> </span><span class="n">native_windows_gui</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="n">nwg</span><span class="p">;</span><span class="w"></span>

<span class="k">fn</span> <span class="nf">clipboard_text</span><span class="p">(</span><span class="n">window</span>: <span class="kp">&amp;</span><span class="nc">nwg</span>::<span class="n">Window</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">nwg</span>::<span class="n">Clipboard</span>::<span class="n">set_data_text</span><span class="p">(</span><span class="n">window</span><span class="p">,</span><span class="w"> </span><span class="s">&quot;Hello!&quot;</span><span class="p">);</span><span class="w"></span>

<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">nwg</span>::<span class="n">Clipboard</span>::<span class="n">data_text</span><span class="p">(</span><span class="n">window</span><span class="p">);</span><span class="w"></span>
<span class="w">    </span><span class="n">assert</span><span class="o">!</span><span class="p">(</span><span class="n">text</span><span class="p">.</span><span class="n">is_some</span><span class="p">());</span><span class="w"></span>
<span class="w">    </span><span class="n">assert</span><span class="o">!</span><span class="p">(</span><span class="o">&amp;</span><span class="n">text</span><span class="p">.</span><span class="n">unwrap</span><span class="p">()</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="o">&amp;</span><span class="s">&quot;Hello!&quot;</span><span class="p">);</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</pre></div><br>

        <h4>Handling custom data</h4>

        It's possible to pass data structure around using the low level clipboard functions. Note that those function are unsafe because there is no way to
        validate the data.

        <br><br>

        When using the low level functions, the clipboard must be manually <b>opened</b> and then <b>closed</b>. Also, when setting data, it's up to the developer
        to <b>empty</b> whatever content was in the clipboard. Failure to do so will result in unknown errors.

<div class="highlight"><pre style="width:auto;"><span></span><span class="k">use</span><span class="w"> </span><span class="n">native_windows_gui</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="n">nwg</span><span class="p">;</span><span class="w"></span>

<span class="cp">#[repr(C)]</span><span class="w"></span>
<span class="cp">#[derive(Clone, Copy)]</span><span class="w"></span>
<span class="k">struct</span> <span class="nc">Hello</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">foo</span>: <span class="kt">usize</span><span class="p">,</span><span class="w"></span>
<span class="w">    </span><span class="n">bar</span>: <span class="p">[</span><span class="kt">u16</span><span class="p">;</span><span class="w"> </span><span class="mi">3</span><span class="p">]</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="k">fn</span> <span class="nf">write_custom_data</span><span class="p">(</span><span class="n">window</span>: <span class="kp">&amp;</span><span class="nc">nwg</span>::<span class="n">Window</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">data</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">Hello</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="n">foo</span>: <span class="mi">6529</span><span class="p">,</span><span class="w"></span>
<span class="w">        </span><span class="n">bar</span>: <span class="p">[</span><span class="mi">0</span><span class="p">,</span><span class="w"> </span><span class="mi">100</span><span class="p">,</span><span class="w"> </span><span class="mi">20</span><span class="p">]</span><span class="w"></span>
<span class="w">    </span><span class="p">};</span><span class="w"></span>

<span class="w">    </span><span class="n">nwg</span>::<span class="n">Clipboard</span>::<span class="n">open</span><span class="p">(</span><span class="n">window</span><span class="p">);</span><span class="w"></span>
<span class="w">    </span><span class="n">nwg</span>::<span class="n">Clipboard</span>::<span class="n">empty</span><span class="p">();</span><span class="w"></span>
<span class="w">    </span><span class="k">unsafe</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="n">nwg</span>::<span class="n">Clipboard</span>::<span class="n">set_data</span><span class="p">(</span><span class="w"></span>
<span class="w">            </span><span class="n">nwg</span>::<span class="n">ClipboardFormat</span>::<span class="n">Global</span><span class="p">(</span><span class="s">&quot;Hello&quot;</span><span class="p">),</span><span class="w"></span>
<span class="w">            </span><span class="o">&amp;</span><span class="n">data</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="o">*</span><span class="k">const</span><span class="w"> </span><span class="n">Hello</span><span class="p">,</span><span class="w"></span>
<span class="w">            </span><span class="mi">1</span><span class="w"></span>
<span class="w">        </span><span class="p">);</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>

<span class="w">    </span><span class="n">nwg</span>::<span class="n">Clipboard</span>::<span class="n">close</span><span class="p">();</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
<span class="w">    </span>
<span class="k">fn</span> <span class="nf">read_custom_data</span><span class="p">(</span><span class="n">window</span>: <span class="kp">&amp;</span><span class="nc">nwg</span>::<span class="n">Window</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="nb">Option</span><span class="o">&lt;</span><span class="n">Hello</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">unsafe</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="n">nwg</span>::<span class="n">Clipboard</span>::<span class="n">open</span><span class="p">(</span><span class="n">window</span><span class="p">);</span><span class="w"></span>
<span class="w">        </span><span class="kd">let</span><span class="w"> </span><span class="n">data</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">nwg</span>::<span class="n">Clipboard</span>::<span class="n">data</span><span class="p">(</span><span class="n">nwg</span>::<span class="n">ClipboardFormat</span>::<span class="n">Global</span><span class="p">(</span><span class="s">&quot;Hello&quot;</span><span class="p">));</span><span class="w"></span>
<span class="w">        </span><span class="n">nwg</span>::<span class="n">Clipboard</span>::<span class="n">close</span><span class="p">();</span><span class="w"></span>
<span class="w">        </span><span class="n">data</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="k">fn</span> <span class="nf">read_custom_data_handle</span><span class="p">(</span><span class="n">window</span>: <span class="kp">&amp;</span><span class="nc">nwg</span>::<span class="n">Window</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="nb">Option</span><span class="o">&lt;</span><span class="n">Hello</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">unsafe</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="n">nwg</span>::<span class="n">Clipboard</span>::<span class="n">open</span><span class="p">(</span><span class="n">window</span><span class="p">);</span><span class="w"></span>
<span class="w">        </span><span class="kd">let</span><span class="w"> </span><span class="n">handle</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">nwg</span>::<span class="n">Clipboard</span>::<span class="n">data_handle</span><span class="p">(</span><span class="n">nwg</span>::<span class="n">ClipboardFormat</span>::<span class="n">Global</span><span class="p">(</span><span class="s">&quot;Hello&quot;</span><span class="p">));</span><span class="w"></span>
<span class="w">        </span><span class="kd">let</span><span class="w"> </span><span class="n">data</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">match</span><span class="w"> </span><span class="n">handle</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">            </span><span class="nb">Some</span><span class="p">(</span><span class="n">h</span><span class="p">)</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">                </span><span class="kd">let</span><span class="w"> </span><span class="n">data_ptr</span>: <span class="o">*</span><span class="k">const</span><span class="w"> </span><span class="n">Hello</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">h</span><span class="p">.</span><span class="n">cast</span><span class="p">();</span><span class="w"></span>
<span class="w">                </span><span class="kd">let</span><span class="w"> </span><span class="n">data</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="o">*</span><span class="n">data_ptr</span><span class="p">;</span><span class="w"></span>
<span class="w">                </span><span class="n">h</span><span class="p">.</span><span class="n">release</span><span class="p">();</span><span class="w"></span>
<span class="w">                </span><span class="nb">Some</span><span class="p">(</span><span class="n">data</span><span class="p">)</span><span class="w"></span>
<span class="w">            </span><span class="p">},</span><span class="w"></span>
<span class="w">            </span><span class="nb">None</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="nb">None</span><span class="w"></span>
<span class="w">        </span><span class="p">};</span><span class="w"></span>

<span class="w">        </span><span class="n">nwg</span>::<span class="n">Clipboard</span>::<span class="n">close</span><span class="p">();</span><span class="w"></span>
<span class="w">        </span><span class="n">data</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</pre></div>
<br><br>
            

    </div>
</div>

<script src="style/rustbook.js"></script>
</body>
</html>
